package com.woniu.defecttracking.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.woniu.defecttracking.dto.GetWorkHoursByDayDto;
import com.woniu.defecttracking.dto.getAccountsByProjectIdDto;
import com.woniu.defecttracking.entity.Account;
import com.woniu.defecttracking.entity.Project;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author tiangle
 * @since 2021-12-31
 */
public interface ProjectMapper extends BaseMapper<Project> {

    @Select("SELECT\n" +
            "   ac.account_username userName,\n" +
            "   r.role_name role\n" +
            "FROM\n" +
            "   project p,\n" +
            "   project_account pa,\n" +
            "   account ac,\n" +
            "   account_role ar,\n" +
            "   role r\n" +
            "WHERE\n" +
            "   p.project_id = pa.project_id\n" +
            "AND pa.account_id = ac.account_id\n" +
            "AND ac.account_id = ar.account_id\n" +
            "AND ar.role_id = r.role_id\n" +
            "and ac.account_isdel=0\n" +
            "and r.role_isdel=0\n" +
            "and p.project_isdel=0\n" +
            "AND pa.project_id = #{projectId} ")
    List<getAccountsByProjectIdDto> selectAccountsByProjectId(String projectId);

//    List selectAllUserList();

    @Select("select *from account")
    IPage<Account> selectAllUserList(Page<?> page);
}
